package com.leff.cards.data;

import java.util.ArrayList;

import org.json.simple.JSONArray;

import com.leff.cards.util.Dictionary;

public class Invitation extends BaseGroup {

	private Invitation() {}
	
	public static Invitation fromDictionary(Dictionary dict) {
		
		Invitation I = new Invitation();
		
		I.id = (Long)dict.get("id");
		I.name = (String)dict.get("name");
		
		I.members = new ArrayList<User>();
		JSONArray usersArr = (JSONArray)dict.get("members");
		for(Object O : usersArr) {
			Dictionary user = Dictionary.fromJSONObject(O);
			I.members.add(User.fromDictionary(user));
		}
		
		return I;
	}
}
